<?php
/*
 * ActionRegistrationBuyer.php
 * for pre-registration validation and action on registration
 * PT BitZero Informatika
 */
require_once APPLICATION_PATH.'/misc/sessionController.php';
class Application_Controllers_Buyer_ActionEditBuyer
{   public $wrongMessage="";
    //Function to do validation  before Registration
    function PreEdit($form){

    }
    //function to execute registration main task
    function onEdit($id,$form){
        $sessionController = new sessionController();
        $actionLog = new Application_Model_DbTable_Actionlog();
        $buyer = new Application_Model_DbTable_Buyers();
        list($d, $m, $y) = explode('-', $form->getValue('date_birth'));
        $mk=mktime(0, 0, 0, $y, $m, $d);
        $dob_disp1=strftime('%Y-%m-%d',$mk);
        $array=array(
              'name'=>$form->getValue('name'),
              'address'=>$form->getValue('address'),
              'mobile_phone'=>$form->getValue('mobile_phone'),
              'home_phone'=>$form->getValue('home_phone'),
              'gender'=>$form->getValue('gender'),
              'date_birth'=>$dob_disp1,
              'active'=>$form->getValue('active'),
              'city'=>$form->getValue('city'),
              'province'=>$form->getValue('province'),
              'zip'=>$form->getValue('zip')
        );

        $this->wrongMessage="'name'=>$form->getValue('name'),
              'address'=>$form->getValue('address'),
              'mobile_phone'=>$form->getValue('mobile_phone'),
              'home_phone'=>$form->getValue('home_phone'),
              'gender'=>$form->getValue('gender'),
              'date_birth'=>$dob_disp1,
              'active'=>$form->getValue('active')";
        $buyer->updateBuyer($id,$array);

                $actionLog->addActionLog($sessionController->getSessionLogId(),
                                            "[".$_SERVER['REMOTE_ADDR']
                                             ."][".$sessionController->getSessionUsername()
                                             ."][".$sessionController->getSessionRole()."]Edit Buyer ".
                                             "Name : ".$form->getValue('name')
                                             ." ID :".$id."");

    }

}
?>
